package com.example.dao;

import com.example.entity.Book;
import com.example.entity.Params;
import com.example.entity.Student;
import com.example.entity.dto.UserDTO;
import com.example.entity.dto.studentInforDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;


@Repository
public interface StudentDao extends Mapper<Student> {

    List<Student> findBySearch(@Param("params") Params params);

    /**
     * 根据姓名考号身份证在学生表中查找是否存在该学生
     * @param book
     * @return
     */
    @Select("select * from student where name = #{name} and id_card = #{idCard} and number = #{adnumber}")
    Student getBy(UserDTO book);

    /**
     * book每提交一次count加一
     */
    @Update("update student set count = count + 1 where name = #{name} and id_card = #{idCard} and number = #{adnumber}")
    void updataCount(UserDTO book);
    @Select("select college,major from student where id_card=#{idCard} ")
    studentInforDTO selectstudentInforByIdCard(UserDTO userDTO);
}
